package com.dfbz.demo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01_List接口常用方法 {

    public static void main(String[] args) {

        List<String> cities=new ArrayList();
        cities.add("南宁");
        cities.add("柳州");
        cities.add("桂林");
        cities.add("贵港");

        List<String> list = cities.subList(0, 2);           // 包头不包尾
        System.out.println(list);


    }
    public static void test(String[] args) {

        List<String> cities=new ArrayList();
        cities.add("南宁");
        cities.add("柳州");
        cities.add("桂林");

        System.out.println(cities);         // [南宁, 柳州, 桂林]
        cities.add(1,"北海");
        System.out.println(cities);         // [南宁, 北海, 柳州, 桂林]

        String city = cities.get(2);       // 柳州
        System.out.println(city);

        cities.remove(0);           // 南宁
        System.out.println(cities);        //  [北海, 柳州, 桂林]

        cities.set(0,"崇左");
        System.out.println(cities);         //  [崇左, 柳州, 桂林]

    }
}
